import React from 'react';
import ReactDOM from 'react-dom';

import {createHashHistory} from 'history';

import {Router, Route, useRouterHistory} from 'react-router'

import {syncHistoryWithStore,RouterStore} from 'mobx-react-router';

import {Provider} from 'mobx-react';

import WeaBlog from 'weaBlog' //umd
// import ComMobx from 'comsMobx'
//import Workplan from './index'
import { WeaLocaleProvider } from 'ecCom'
const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'blog');

// const allStore = Workplan.store;
const routing = new RouterStore();


const allStore = {
    routing,
    ...WeaBlog.store,
    // ...ComMobx.store,
}

// allStore.routing = routing;
const BlogRoute = WeaBlog.Route;

const browserHistory = useRouterHistory(createHashHistory)({
  queryKey: '_key',
  basename: '/'
});

const history = syncHistoryWithStore(browserHistory, allStore.routing);

class Home extends React.Component {
  render() {
    return (
      <WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@va3vqi`}>
        {this.props.children}
      </WeaLocaleProvider>
    );
  }
}

const HisWeiboSingle = WeaBlog.components.HisWeiboSingle;
// WeaBlogDict.addWindowFunc();
class Root extends React.Component {
  render() {
    return (
      <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@hxmvkc`} {...allStore}>
        <Router ecId={`${this && this.props && this.props.ecId || ''}_Router@kxw3dz`} history={history}>
          <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@5c4tno`} name="main" onEnter={getLocaleLabel} breadcrumbName="入口" path="/main" component={Home}>
            {BlogRoute}
          </Route>
          <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@grwaes`} path="user/:userId" onEnter={getLocaleLabel} component={HisWeiboSingle} />
        </Router>
      </Provider>
    )
  }
}

ReactDOM.render(<Root ecId={`${this && this.props && this.props.ecId || ''}_Root@vr5fhg`}/>, document.getElementById('container'));
